<template>
  <div style="color: #666">
    <div
        style="margin:10px 0;background-color: turquoise;height: 80px;width: 100%;text-align: center;line-height: 80px;border-radius: 10px">
      <span
          style="color: #107bad ;font-size: 28px;">-----------发&nbsp;&nbsp;布&nbsp;&nbsp;留&nbsp;&nbsp;言------------</span>
    </div>
    <div style="padding: 40px">
<!--      <span style="font-size: 20px;display: inline-block;margin: 5px">留言标题:</span>-->
<!--      <el-input type="text" style="padding: 10px" placeholder="请输入标题"-->
<!--                maxlength="40" show-word-limit size="max"></el-input>-->
      <span style="font-size: 20px;display: inline-block;margin: 5px"  >留言内容:</span>
      <el-input type="textarea" style="padding: 10px;font-size: 16px" placeholder="请输入内容"
                v-model="sysMessage.message" maxlength="300" show-word-limit size="max" rows="8"></el-input>
      <el-button type="primary" style="width: 12%;margin-left:82% " size="max" @click="save">发布 </el-button>
<!--      <i class="el-icon-circle-plus-outline"></i>-->
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "PublishMessage",
  data() {
    return {
      sysMessage:{},
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
    }
  },
  created() {
  },
  methods: {
    // 发布留言
    save() {
      if(this.sysMessage.message===undefined){
        return alert('标题或内容不能为空')
      }
      console.log(this.sysMessage)
      this.sysMessage.createUser=this.user.nickname
      // 将留言标题(message.name)和留言内容(message.content)存储到数据库
      this.request.post("/message", this.sysMessage).then(res => {
        if (res.code === '200') {
          this.$message.success("保存成功")
        } else {
          this.$message.error("保存失败")
        }
      })
    },
  }
}
</script>

<style scoped>

</style>
